<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>我的订单 - 达内学子商城</title>
    <link href="/user/css/my.order.css" rel="stylesheet" />
    <link href="/user/css/header.css" rel="stylesheet" />
    <link href="/user/css/footer.css" rel="stylesheet" />
    <link href="/user/css/set.css" rel="stylesheet" />
    <link href="/commons/css/bootstrap.css" rel="stylesheet" />
</head>
<body>
<div id="header">
    <!--顶部导航栏--> <!--注意引入的路径-->
    <div th:replace="~{user/commons/commons::header}"></div>
    <!-- 主导航-->

    <!-- 主导航-->
    <nav id="nav1">
        <!-- 我的订单导航栏-->
        <div id="nav_order" class="lf">
            <ul>
                <li></li>
            </ul>
        </div>
    </nav>
</div>
<!--我的订单内容区域 #container-->
<div id="container" class="clearfix">
    <!-- 左边栏-->

    <!-- 右边栏-->
    <div class="rightsidebar_box rt" >
        <div class="order_empty">
            <div id="cover" class="rt">
                <form name="form1" id="fm-changep" method="post" action="">
                    <div class="txt">
                        <p>账户管理
                            <span>
                        <a href="index.jsp">继续购物</a>
                    </span>
                        </p>
                        <input name="user.uname" id="uname" type="hidden" value="user01" />
                        <div class="text">
                            <input type="email" placeholder="请输入绑定的邮箱号" autocomplete="off" name="email" id="email">
                        </div>
                        <div class="text">
                            <input type="button" value="获取验证码" name="btnSendCode1" class="btn btn-warning" id="btnSendCode1" onClick="sendMessage1()">
                        </div>
                        <div class="text">
                            <input type="text" autocomplete="off" placeholder="邮箱验证码" name="code" id="code" >
                            <div id="pwdValidate"></div>
                        </div>
                        <div class="text">
                            <input class="btn btn-success" type="button" value="下一步" id="bt-next" onclick="binding()"/>
                            <div id="changeFail"></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- 品质保障，私人定制等-->
<div id="foot_box">
    <div class="icon1 lf">
        <img src="/user/img/footer/icon1.png" alt=""/>
        <h3>品质保障</h3>
    </div>
    <div class="icon2 lf">
        <img src="/user/img/footer/icon2.png" alt=""/>
        <h3>私人定制</h3>
    </div>
    <div class="icon3 lf">
        <img src="/user/img/footer/icon3.png" alt=""/>
        <h3>学员特供</h3>
    </div>
    <div class="icon4 lf">
        <img src="/user/img/footer/icon4.png" alt=""/>
        <h3>专属特权</h3>
    </div>
</div>
<!-- 页面底部-->
<div th:replace="~{user/commons/commons::foot}"></div>
</body>
<script src="/user/js/jquery-3.1.1.min.js"></script>
<script src="/user/js/index.js"></script>
<script src="/user/js/jquery.page.js"></script>
<script src="/user/js/order.js"></script>
<script type="text/javascript">
    var emailReg = /(^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$)/;//邮箱正则
    var count = 60; //间隔函数，1秒执行
    var InterValObj1; //timer变量，控制时间
    var curCount1;//当前剩余秒数
    /*第一*/
    function sendMessage1() {
        curCount1 = count;
        var email = $.trim($('#email').val());
        if (!emailReg.test(email)) {
            alert(" 请输入有效的邮箱号码");
            return false;
        }
//向后台发送处理数据
        $.ajax({
            type:'post',
            url:'/user/page/emailCheck',
            data:'email='+email,
            success:function(msg){
                if(msg=='ok'){
                    alert("验证码已发送！");
                }else{
                    alert("邮箱不存在！");
                }
            }
        });
        //设置button效果，开始计时
        $("#btnSendCode1").attr("disabled", "true");
        $("#btnSendCode1").val( + curCount1 + "秒再获取");
        InterValObj1 = window.setInterval(SetRemainTime1, 1000); //启动计时器，1秒执行一次


    }
    function SetRemainTime1() {
        if (curCount1 == 0) {
            window.clearInterval(InterValObj1);//停止计时器
            $("#btnSendCode1").removeAttr("disabled");//启用按钮
            $("#btnSendCode1").val("重新发送");
        }
        else {
            curCount1--;
            $("#btnSendCode1").val( + curCount1 + "秒再获取");
        }
    }
    /*提交*/
    function binding(){
        var code = $.trim($('#code').val());
        if (code==null){
            alert("请输入正确的邮箱！")
            return;
        }
        //向后台发送处理数据
        $.ajax({
            type:'post',
            url:'/user/page/codeCheck',
            data:'code='+code,
            success:function(msg){
                if(msg=='ok'){
                    window.location.href="/password-change.html";
                }else if(msg=='timeOut'){
                    alert("验证码超时！请重新获取。");
                }else {
                    alert("验证码错误！");
                }
            }
        });
    }

</script>
</html>
